<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!-- **********************************************
	***************************************************
				nav & search & user   start
	***************************************************
	*************************************************** -->
<c:if test="${not empty navlist }">
	<div class="navbar navbar-inverse navbar-fixed-top">
		<div class="container">
			<div class="navbar-header">
				<button type="button" class="navbar-toggle" data-toggle="collapse"
					data-target="#navbar-collapse-1" aria-expanded="false">
					<span class="sr-only">Toggle navigation</span> <span
						class="icon-bar"></span> <span class="icon-bar"></span> <span
						class="icon-bar"></span>
				</button>
				<a class="navbar-brand" href="<en:path/>${navlist[0].path }">${navlist[0].name }</a>
			</div>
			<div class="collapse navbar-collapse" id="navbar-collapse-1">
				<ul class="nav navbar-nav">
					<c:forEach begin="1" items="${navlist }" var="n">
						<li><a href="<en:path/>${n.path }">${n.name }</a></li>
					</c:forEach>
				</ul>
				<ul class="nav navbar-nav">
					<li>&nbsp;</li>
					<li>&nbsp;</li>
					<li>&nbsp;</li>
				</ul>
				<form action="#" class="nav navbar-form navbar-left" role="search">
					<div class="form-group">
						<input type="text" class="form-control" name="keyword"
							placeholder="关键字">
					</div>
					<button type="submit" class="btn btn-primary">Submit</button>
				</form>


				<!-- denglu s -->
				<ul class="nav navbar-form navbar-right">
					<div class="btn-group">
						<button type="button" class="btn btn-primary"
							onclick="index.login()">登陆</button>
						<button type="button" class="btn btn-primary dropdown-toggle"
							data-toggle="dropdown" aria-expanded="true">
							<span class="caret"></span>
						</button>
						<ul class="dropdown-menu">
							<li><a href="javascript:void(0)" onclick="index.loginout()">退出</a></li>
						</ul>
					</div>
				</ul>
				<!-- denglu e -->
			</div>
		</div>
	</div>
</c:if>


<!-- ***************************************************
	***************************************************
				index user login model
	***************************************************
	*************************************************** -->

<div class="form" style="display: none;">
	<div class="form-inline form-group">
		<div class="input-group">
			<span class="input-group-addon"><span
				class="glyphicon glyphicon-user"></span></span><input type="text"
				id="username" class="form-control" placeholder="用户名">
		</div>
	</div>
	<div class="form-inline form-group">
		<div class="input-group">
			<span class="input-group-addon"><span
				class="glyphicon glyphicon-lock"></span></span> <input type="password"
				id="password" class="form-control" placeholder="密码">
		</div>
	</div>
</div>
<!-- **********************model end******************** -->

<script type="text/javascript">
	var index = {
		login : function() {
			$("input[id=username]").val("");
			$("input[id=password]").val("");

			layer.open({
				type : 1,
				btn : [ '登陆', '取消' ],
				title : '用户登陆',
				content : $(".form"),
				yes : function() {
					var username = $("input[id=username]").val();
					var password = $("input[id=password]").val();
					if (username == "" || username == null) {
						layer.msg("用户名不能为空", {
							icon : 2
						});
						return;
					}

					if (password == "" || password == null) {
						layer.msg("密码不能为空", {
							icon : 2
						});
						return;
					}

					var layer_index = layer.load(1);

					$.ajax({
						url : '<en:path/>/ajaxlogin.html',
						data : {
							'username' : username,
							'password' : password
						},
						dataType : 'json',
						success : function(data) {
							layer.close(layer_index);
							if (data.code == "0") {
								layer.closeAll();
								layer.msg(data.msg, {
									icon : 1
								});
							} else {
								layer.msg(data.msg, {
									icon : 2
								});
							}
						}
					});
				}
			});
		},
		loginout : function() {
			layer.confirm('是否进行退出?', {
				icon : 3
			}, function(index) {
				layer.msg(index);
			});
		}
	}
</script>
